/* 用户管理api */
import { user } from "@/api/request";
/* 获取用户 */
export function get(parameter: object) {
  return user({
    url: `/user`,
    method: "get",
    params: parameter,
  });
}

export function getRoles(parameter: object) {
  return user({
    url: `/roleuser`,
    method: "get",
    params: parameter,
  });
}

/* 更新项目 */
export function update(data: object) {
  return user({
    url: `/user/update`,
    method: "post",
    data: data,
  });
}

export function add(data: any) {
  return user({
    url: `/user`,
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data",
      //   "Content-Type": "false",
    },
  });
}

export function del(id: number) {
  return user({
    url: `/user/delete/${id}`,
    method: "get",
  });
}

export function delroleuser(parameter: object) {
  return user({
    url: `/roleuser/deletebyroleadmin`,
    method: "get",
    params: parameter,
  });
}
export function getOtherRole(parameter: object) {
  return user({
    url: `/roleuser/otherrole`,
    method: "get",
    params: parameter,
  });
}

export function getresources(parameter: object) {
  return user({
    url: `/roleresource/userresource`,
    method: "get",
    params: parameter,
  });
}

export function addroleuser(data: object) {
  return user({
    url: `/roleuser`,
    method: "post",
    data: data,
  });
}
// 用户登陆
export function login(data: object) {
  return user({
    url: `/user/login`,
    method: "post",
    data: data,
  });
}

export function startService(parameter: string) {
  return user({
    url: `/user/start`,
    method: "get",
    params: parameter,
  });
}

export function shutdown() {
  return user({
    url: `/user/shutdown`,
    method: "get"
  });
}
export default {
  login,
  get,
  add,
  del,
  update,
  getRoles,
  delroleuser,
  addroleuser,
  getOtherRole,
  getresources,
  startService,
  shutdown
};
